fix: scope type should be string instead of int #3337
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem description
Since the v2.0.1 update, the
oauth2_token_response
model has been renamed and updated too_auth2_token_exchange
. Along with that, an issue occurred where thescope
field of the token response was expected to be of typeint
(for some reason) instead ofstring
as it should be, based on RFC 6749 and previous versions of hydra SDK.Root of the problem
As figured out by @aeneasr and @jonas-jonas in ory/sdk#223, this problem seems to be caused by handler.go#L827. As mentioned earlier, the scope field should be of type
string
instead ofint
, as seen in the proposed change of this PR.Examples of the problem
These examples show how this change affected the generated python and go clients, but the same behaviour can be found in the rest of the clients. I compare the previous version 1.11.0, which worked with no issues, to the latest version 2.0.1, which cannot complete the token exchange flow successfully.
Python Client
Before (oauth2_token_response.py#L88)
After (o_auth2_token_exchange.py#L89)
Go Client
Before (model_oauth2_token_response.go#L23)
After (model_o_auth2_token_exchange.go#L29)
Related issue(s)
This PR came out from ory/sdk#220 and ory/sdk#223.
Importance of the solution
In my opinion, the proposed solution is of high importance. Right now, with the current version of the generated clients, the token change flow, which is the core function of this library, is not working. Hopefully, the suggested update is going to solve this type mismatch and bring the token flows back to normal.
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
security@ory.sh) from the maintainers to push
the changes.
works.